function findText_old(searchText)//查找匹配文本
{
    var content = $('#content').html();//获取html全文
    $('#content').html(content);

        
    if (searchText.length == 0) {
        return false;
    }

    var tmpRegExp = new RegExp(">", 'g');
    var tmp2RegExp = new RegExp("<", 'g');
    var regExp = new RegExp(searchText, 'g');
    var tmpContent = content.replace(tmpRegExp, ">\n");
    var tmpContent = tmpContent.replace(tmp2RegExp, "\n<");

    var htmlTexts = tmpContent.split('\n');

    var finalHtml = "";
    for(var i = 0 ;i < htmlTexts.length;i++)
    {
        
        if (htmlTexts[i].indexOf('<') == -1) {
           
            htmlTexts[i] = htmlTexts[i].replace(regExp, '<span id="result" style="background:yellow;color:red;">' + searchText + '</span>');
        }
        finalHtml += htmlTexts[i];

    }
    
    $('#content').html(finalHtml);
};

function findText(searchText)
{
	//console.log(searchText)
    searchText = searchText.toUpperCase();
    var regExp = new RegExp(searchText, 'g');
    var content = $('#content').html();//获取html全文
    var tags = ["div","p","a","td","th"];
    for (var ti = 0 ; ti < tags.length ; ti++)
    {
        var elss = document.body.getElementsByTagName(tags[ti]);

        for(var ei = 0 ; ei < elss.length ; ei++)
        {
            //alert(elss[ei].innerHTML);
            if(elss[ei].innerText == elss[ei].innerHTML)
            {
                elss[ei].innerHTML = elss[ei].innerText.replace(regExp, '<span id="result" style="background:yellow;color:red;">' + searchText + '</span>');
            }

        }
    }  
}

function getQueryVariable(variable) {
    var query = window.location.search.substring(1);
    var vars = query.split("&");
    for (var i = 0; i < vars.length; i++) {
        var pair = vars[i].split("=");
        if (pair[0] == variable) {
            return decodeURIComponent(pair[1]);
        }
    }
    return (false);
}

$(function(){
	var keyWord = $("#key",window.parent.document).val();
	if(keyWord != null && keyWord != ''){
		findText(keyWord);
	}
})
